from __future__ import division

class Player():
    '''Player that does what everyone else seems to be doing.'''
    
    def __init__(self):
        self.name = 'CWJ_Copycat'
        self.last_choices = None
        self.last_r_avg = None
    
    def hunt_choices(self, round_number, current_food, current_reputation, m,
            player_reputations):
        # Always hunt on round 1.
        if round_number == 1:
            choices = ['h' for r in player_reputations]
        # If group dynamic is slacking, slack.
        elif self.last_r_avg <= 0.5:
            choices = ['s' for r in player_reputations]
        # Otherwise, copy what they did last time.
        else:
            choices = self.last_choices
        # Trim as needed
        while len(choices) > len(player_reputations):
            choices.pop()
        return choices
    
    def hunt_outcomes(self, food_earnings):
        self.last_choices = ['h' if payout >= 0 else 's' for payout in food_earnings]
        self.last_r_avg = self.last_choices.count('h') / len(food_earnings)
    
    def round_end(self, award, m, number_hunters):
        pass
